Index: src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java =================================================================== --- src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java (revision 208897) +++ src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java (working copy) @@ -68,6 +68,7 @@ * work just fine. * * @author Geir Magnusson Jr. + * @author Aki Nieminen * @version $Id$ */ public class ClasspathResourceLoader extends ResourceLoader @@ -91,7 +92,7 @@ * @throws ResourceNotFoundException if template not found * in classpath. */ - public synchronized InputStream getResourceStream( String name ) + public InputStream getResourceStream( String name ) throws ResourceNotFoundException { InputStream result = null; Index: src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java =================================================================== --- src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java (revision 208897) +++ src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java (working copy) @@ -20,6 +20,8 @@ import java.util.Hashtable; import java.util.Vector; +import java.util.Map; +import java.util.HashMap; import org.apache.velocity.util.StringUtils; import org.apache.velocity.runtime.resource.Resource; @@ -54,6 +56,7 @@ *
* * @author Dave Bryson + * @author Aki Nieminen * @version $Id$ */ public class JarResourceLoader extends ResourceLoader @@ -63,14 +66,14 @@ * Key = the entry *excluding* plain directories * Value = the JAR URL */ - private Hashtable entryDirectory = new Hashtable(559); + private Map entryDirectory = new HashMap(559); /** * Maps JAR URLs to the actual JAR * Key = the JAR URL * Value = the JAR */ - private Hashtable jarfiles = new Hashtable(89); + private Map jarfiles = new HashMap(89); /** * Called by Velocity to initialize the loader @@ -79,6 +82,9 @@ { rsvc.info("JarResourceLoader : initialization starting."); + // rest of Velocity engine still use legacy Vector + // and Hashtable classes. Classes are implicitly + // synchronized even if we don't need it. Vector paths = configuration.getVector("path"); /* @@ -155,7 +161,7 @@ * Copy all the entries into the entryDirectory * It will overwrite any duplicate keys. */ - private synchronized void addEntries( Hashtable entries ) + private void addEntries( Hashtable entries ) { entryDirectory.putAll( entries ); } @@ -169,7 +175,7 @@ * @throws ResourceNotFoundException if template not found * in the file template path. */ - public synchronized InputStream getResourceStream( String source ) + public InputStream getResourceStream( String source ) throws ResourceNotFoundException { InputStream results = null; @@ -230,13 +236,3 @@ return 0; } } - - - - - - - - - - Index: src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java =================================================================== --- src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java (revision 208897) +++ src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java (working copy) @@ -22,13 +22,14 @@ import java.io.BufferedInputStream; import java.io.FileNotFoundException; -import java.util.Hashtable; -import java.util.Vector; +import java.util.Collections; +import java.util.ArrayList; +import java.util.List; +import java.util.HashMap; +import java.util.Map; import org.apache.velocity.util.StringUtils; - import org.apache.velocity.runtime.resource.Resource; - import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.commons.collections.ExtendedProperties; @@ -37,6 +38,7 @@ * A loader for templates stored on the file system. * * @author Jason van Zyl + * @author Aki Nieminen * @version $Id$ */ public class FileResourceLoader extends ResourceLoader @@ -44,25 +46,31 @@ /** * The paths to search for templates. */ - private Vector paths = null; + private List paths; /** * Used to map the path that a template was found on * so that we can properly check the modification - * times of the files. + * times of the files. This is synchronizedMap + * instance. */ - private Hashtable templatePaths = new Hashtable(); + private Map templatePaths; public void init( ExtendedProperties configuration) { rsvc.info("FileResourceLoader : initialization starting."); - paths = configuration.getVector("path"); + paths = new ArrayList(); + paths.addAll( configuration.getVector("path") ); + /** + * Create synchronized map instance + */ + templatePaths = Collections.synchronizedMap(new HashMap()); + /* * lets tell people what paths we will be using */ - int sz = paths.size(); for( int i=0; i < sz; i++) @@ -82,7 +90,7 @@ * @throws ResourceNotFoundException if template not found * in the file template path. */ - public synchronized InputStream getResourceStream(String templateName) + public InputStream getResourceStream(String templateName) throws ResourceNotFoundException { /* @@ -132,8 +140,7 @@ * from so that we can check its modification * time. */ - - templatePaths.put(templateName, path); + templatePaths.put(templateName, path); return inputStream; } } Index: build/build.xml =================================================================== --- build/build.xml (revision 208897) +++ build/build.xml (working copy) @@ -86,7 +86,7 @@